/*
 * 格言组件
 */
import axios from 'axios';
import React, { useEffect, useState } from 'react';
import { Api_URL } from '../any_enum';

const myStyle = {
  one: { textAlign: 'center', cursor: 'default' },
  two: { transform: 'translate(1rem)' },
};

const Aphorism = () => {
  const [data, setData] = useState<any>(null);

  useEffect(() => {
    axios({
      method: 'get',
      url: Api_URL.XC_API,
    }).then((res: any) => {
      res?.status === 200 && res?.data && setData(res.data.data);
    });
  }, []);

  return (
    <>
      <p>「 {data?.sentence ?? null}」</p>
      <p style={myStyle.two}>
        <span>——</span> {data?.fromWho ?? null}{' '}
        {data?.from ? `《${data.from}》` : null}
      </p>
    </>
  );
};

export default Aphorism;
